//
//  VIPRoomManager.m
//  TTProduct
//
//  Created by My mac on 2018/8/27.
//  Copyright © 2018年 TTProduct. All rights reserved.
//

#import "VIPRoomManager.h"
#import "VIPBaseRTCModel.h"
#import "VIPRTCZegoModel.h"
#import "VIPRTCAgoraModel.h"
#import "VIPLiveVideoManager.h"
#import <MJExtension/MJExtension.h>

@interface VIPRoomManager()

@property (nonatomic, strong) VIPRoomModel *room;

@end

@implementation VIPRoomManager

static VIPRoomManager *_instance = nil;
+ (instancetype)shareManager {
    static dispatch_once_t token;
    dispatch_once(&token, ^{
        _instance = [[self alloc] init];
    });
    return _instance;
}

- (void)updateDMSKeys:(VIPRoomModel *)obj {
    _room = obj;
    
    Class dataModelClass = nil;
    VIPRTCServerType type = [obj.rtc[@"type"] integerValue];
    if (type == VIPRTCServerAgora) {
        dataModelClass = [VIPRTCAgoraModel class];
    }
    
    if (type == VIPRTCServerZego) {
        dataModelClass = [VIPRTCZegoModel class];
    }

    obj.rtcModel = [dataModelClass mj_objectWithKeyValues:obj.rtc];;
    [[VIPLiveVideoManager shareManager] bindingRoomInfo:obj];
}

@end
